<template>
  <view :class="mask?'showMask':''">
    <view>
      <view class="nav"></view>
      <view class="top">
        <view class="user" @click="login">
          <view class="bigText">
            {{$store.state.userInfo.unionId?$store.state.userInfo.u_name:'未登录/注册'}}
          </view>
          <view :class="['smallText',$store.state.userInfo.unionId?'iconfont icon-write':'']">
            {{$store.state.userInfo.unionId?'我的在线简历':'点击头像可登录/注册'}}
          </view>
        </view>
        <view class="pic" v-if="$store.state.hasLogin" @click="editInfo">
          <image :src="$store.state.userInfo.u_pic" mode=""></image>
        </view>
      </view>
      <view class="grid">
        <grid-item v-for="item in gridList" :key="item.id" :className="item.class" :title="item.title"></grid-item>
      </view>
      <view class="assistant">
        <view class="title">
          <view>求职助手</view>
          <text>更多<text class="iconfont icon-right"></text></text>
        </view>
        <view class="items">
          <view class="item">
            <view class="left">
              <view class="bigText">
                简历刷新
              </view>
              <view class="smallText">
                提升简历活跃
              </view>
            </view>
            <view class="right">
              <view class="iconfont icon-jlsx"></view>
            </view>
          </view>
          <view class="item">
            <view class="left">
              <view class="bigText">
                职业测评
              </view>
              <view class="smallText">
                帮助职业定位
              </view>
            </view>
            <view class="right bgCD95FE">
              <view class="iconfont icon-zycp"></view>
            </view>
          </view>
        </view>
      </view>
      <view class="list">
        <view class="item" hover-class="active" v-for="item in listOne" :key='item.icon'
          @click="listItemClick(item.path)">
          <view class="item-inner">
            <view :class="item.icon">
              <text>{{item.title}}</text>
            </view>
            <text class="iconfont icon-right"></text>
          </view>
        </view>
        <view class="line"></view>
        <view class="item" hover-class="active" v-for="item in listTwe" :key='item.icon'
          @click="listItemClick(item.path)">
          <view class="item-inner">
            <view :class="item.icon">
              <text>{{item.title}}</text>
            </view>
            <text class="iconfont icon-right"></text>
          </view>
        </view>
      </view>
      <view class="footer">
        <view class="item">
          客服电话：17361398280 工作时间：9:30-18:30
        </view>
        <view class="item">
          老年人直连热线：17361398280 工作时间：9:30-18:30
        </view>
        <view class="item">
          人力资源许可证|营业执照
        </view>
        <view class="item">
          朝阳区人社局监督电话：17361398280，(17361398280)
        </view>
      </view>
    </view>
    <view class="mask" @click="maskClick" v-if="mask">
      <view class="inner" @click.stop="nullFn">
        <view class="title">
          登录或注册
        </view>
        <view class="login" @click="login">
          微信账号快速登录
        </view>
        <view class="tip">
          登录代表您已同意海雄直聘<text>《用户协议》</text>和<text>《隐私政策》</text>
        </view>
      </view>
    </view>

  </view>
</template>

<script>
  export default {
    data() {
      return {
        gridList: [{
            id: 1,
            class: 'iconfont icon-resume',
            title: '在线简历'
          },
          {
            id: 2,
            class: 'iconfont icon-upLoad',
            title: '附件简历'
          },
          {
            id: 3,
            class: 'iconfont icon-wdms',
            title: '我的面试'
          },
          {
            id: 4,
            class: 'iconfont icon-jobSub',
            title: '职位订阅'
          }
        ],
        listOne: [{
            title: "我的收藏",
            icon: 'iconfont icon-shoucang',
            path: '../collection/collection'
          },
          {
            title: "我的发现",
            icon: 'iconfont icon-wdfx'
          },
          {
            title: "隐私设置",
            icon: 'iconfont icon-xianshi'
          },
        ],
        listTwe: [{
            title: "我要招聘",
            icon: 'iconfont icon-wyzp',
            path: '../become/become'
          },
          {
            title: "直直公益",
            icon: 'iconfont icon-gongyi'
          },
          {
            title: "意见反馈",
            icon: 'iconfont icon-yijian'
          },
        ],
        mask: false
      }
    },
    onReady() {},
    methods: {
      login() {
        if (this.$store.state.hasLogin) {
          // 编辑
          console.log('编辑')
        } else {
          // 登录
          this.$store.dispatch('login')
        }
      },
      maskClick() {
        this.mask = false
      },
      nullFn() {},
      logout() {
        uni.removeStorage({
          key: 'boss',
          success(res) {
            this.$store.commit('setHasLogin', false)
          },
          fail(err) {
            console.log(err)
          }
        })
      },
      editInfo() {
        uni.navigateTo({
          url: '../personalInfo/personalInfo'
        })
      },
      listItemClick(path) {
        if (!this.$store.state.hasLogin) return this.mask = true
        uni.navigateTo({
          url: path
        })
      }
    }
  }
</script>

<style lang="scss">
  .nav {
    width: 750rpx;
    height: 146rpx;
    background: $uni-color-primary;
    position: fixed;
    top: var(--window-top);
    left: 0;
    z-index: 20;
  }

  .top {
    height: 224rpx;
    padding: 210rpx 40rpx 0;
    width: 670rpx;
    background: $uni-color-primary;
    display: flex;
    justify-content: space-between;
    align-items: center;

    .user {
      color: $uni-text-color-inverse;

      .bigText {
        font-size: 54rpx;
      }

      .smallText {
        font-size: 30rpx;
      }
    }

    .pic {
      width: 134rpx;
      height: 134rpx;
      border-radius: 50%;

      image {
        width: 134rpx;
        height: 134rpx;
        border-radius: 50%;
      }
    }
  }

  .grid {
    display: flex;
    align-items: center;
    justify-content: space-around;
    height: 214rpx;
    background: $uni-bg-color;
  }

  .assistant {
    .title {
      width: 670rpx;
      display: flex;
      margin: auto;
      justify-content: space-between;
      align-items: center;

      view {
        font-size: 40rpx;
        font-weight: bold;
      }

      text {
        color: $uni-text-color-grey;
        font-size: 30rpx;
      }
    }

    .items {
      width: 670rpx;
      margin: auto;
      margin-top: 40rpx;
      display: flex;
      justify-content: space-between;

      .item {
        width: 264rpx;
        padding: 0 30rpx;
        height: 140rpx;
        box-shadow: 2rpx 2rpx 30rpx 1rpx #eee;
        display: flex;
        justify-content: space-between;
        align-items: center;
        border-radius: 10rpx;

        .bigText {
          font-size: 40rpx;
          font-weight: bold;
        }

        .smallText {
          font-size: 24rpx;
          color: $uni-text-color-grey;
        }

        .right {
          width: 78rpx;
          height: 78rpx;
          background: #81AFE6;
          border-radius: 24rpx;
          line-height: 78rpx;
          text-align: center;
          color: $uni-text-color-inverse;

          .iconfont {
            font-size: 50rpx;
          }
        }

        .bgCD95FE {
          background: #CD95FE;
        }
      }
    }
  }

  .list {
    margin-top: 40rpx;

    .item {
      .item-inner {
        width: 670rpx;
        height: 108rpx;
        line-height: 108rpx;
        display: flex;
        margin: auto;
        justify-content: space-between;

        text {
          margin-left: 30rpx;
          font-size: 34rpx;
          color: $uni-text-color;
        }

        .iconfont {
          font-size: 40rpx;
          color: $uni-text-color;
        }

        .icon-right {
          color: $uni-text-color-grey;
        }
      }
    }

    .active {
      background: #F7F7F7;
    }

    .line {
      width: 670rpx;
      height: 1rpx;
      margin: 24rpx auto;
      background: $uni-bg-color-grey;
    }
  }

  .footer {
    margin-top: 108rpx;
    padding-bottom: 64rpx;
    z-index: 19;

    .item {
      text-align: center;
      color: $uni-text-color-grey;
      font-size: 26rpx;
      margin-bottom: 14rpx;
    }
  }

  .showMask {
    overflow: hidden;
    height: 100vh;
  }

  .mask {
    position: absolute;
    background: rgba(0, 0, 0, .6);
    display: flex;
    width: 750rpx;
    height: calc(100% - 146rpx);
    top: 146rpx;
    left: 0;

    .inner {
      width: 486rpx;
      height: 364rpx;
      background: $uni-bg-color;
      margin: auto;
      border-radius: 8rpx;
      padding: 0 38rpx;

      .title {
        font-size: 40rpx;
        text-align: center;
        height: 133rpx;
        line-height: 134rpx;
      }

      .login {
        height: 84rpx;
        line-height: 84rpx;
        text-align: center;
        background: $uni-color-primary;
        color: #fff;
        border-radius: 8rpx;
      }

      .tip {
        margin-top: 40rpx;
        color: $uni-text-color-grey;
        font-size: 26rpx;

        text {
          color: $uni-color-primary;
        }
      }
    }
  }
</style>
